#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
using namespace std;


int main()
{
	string s1(10, 'x');
	for (auto a : s1)
		cout << a << ' ';

	cout << endl;

	s1.resize(5);
	for (auto a : s1)
		cout << a << ' ';

	cout << endl;

	s1.resize(20);
	for (auto a : s1)
		cout << a << ' ';
	return 0;
}


int main7()
{
	string s1;
	
	size_t n = s1.max_size();
	cout << n << endl;
	//string s2(n, '1');

	return 0;
}



int main6()
{
	std::string s1("This is a string");

	std::string::const_reverse_iterator crit1 = s1.crbegin();
	while (crit1 != s1.crend())
	{
		cout << *crit1 << " ";
		crit1++;
	}
	cout << endl;

	auto crit2 = s1.crbegin();
	while (crit2 != s1.crend())
	{
		cout << *crit2 << " ";
		crit2++;
	}
	return 0;
}


//class Solution {
//public:
//	int minOperations(vector<int>& nums, int x)
//	{
//		int sum = 0;
//		for (auto a : nums) sum += a;
//		int target = sum - x;
//
//		if (target < 0) return -1;
//		int ret = -1;
//		for (int left = 0, right = 0, tmp = 0; right < nums.size(); right++)
//		{
//			tmp += nums[right];
//			while (tmp > target)
//				tmp -= nums[left++];
//			if (target == tmp)
//				ret = max(ret, right - left + 1);
//		}
//		if (ret == -1) return -1;
//		else return nums.size() - ret;
//
//	}
//};


//int main5()
//{
//	std::string s1("abcde");
//	cout << ++*(s1.cbegin()) <<endl;
//
//	return 0;
//}


int main4()
{
	std::string s1("This is a string");

	std::string::reverse_iterator rit1 = s1.rbegin();
	while (rit1 != s1.rend())
	{
		cout << *rit1 <<" ";
		rit1++;
	}
	cout << endl;
	return 0;
}


int main3()
{
	std::string s1("abcdefg");

	std::string::iterator it1 = s1.begin();
	while (it1 != s1.end())
	{
		cout << *it1 << " ";
		it1++;
	}
	cout << endl;

	std::string::iterator it2 = s1.begin();
	while (it2 != s1.end())
	{
		(*it2)++;
		cout << *it2 << " ";
		it2++;
	}
	cout << endl;
	return 0;
}


//using namespace std;
int main2()
{
	std::string s1("abcdefg");
	cout << *(s1.end()) << endl;
	return 0;
}

//using std::cout;
//using std::cin;
//using std::endl;

int main1()
{
	std::string s1("hellow");
	std::string s3("This is a string");
	std::string s2("abcdefg");

	std::string::iterator it1 = s1.begin();
	while (it1 != s1.end())
	{
		cout << *it1 << " ";
		it1++;
	}
	cout << endl;

	std::string::iterator it2 = s2.begin();
	while (it2 != s2.end())
	{
		(*it2)++;
		cout << *it2 << " ";
		it2++;
	}
	cout << endl;

	std::string::const_reverse_iterator crit = s2.crbegin();

	return 0;
}